/*
 * @Author: CodeHare
 * @Date: 2023-10-14 11:33:39
 * @LastEditors: yangni 920556271@qq.com
 * @LastEditTime: 2024-02-29 09:41:26
 * @Description:  EMS指令集
 */

import 'package:yt_devops/pages/devices/device_tab/device_detail/ems/common/instruct_model.dart';

/// 指令集
abstract class InstructionSetStrategy {
  Map<String, dynamic>? trigger(
    String? deviceId,
    SettingReqParams? requestParams,
  );
}

/// 系统工作模式（风冷、液冷）
class SystemOperatingMode implements InstructionSetStrategy {
  @override
  Map<String, dynamic>? trigger(
    String? deviceId,
    SettingReqParams? requestParams,
  ) {
    requestParams!.deviceId = deviceId;
    requestParams.serviceId = "systemOperatingMode";

    return {
      "deviceId": requestParams.deviceId,
      "serviceId": requestParams.serviceId,
      "input": requestParams.input,
    };
  }
}

/// 系统工作状态（风冷、液冷）
class SystemWorkingStatus implements InstructionSetStrategy {
  @override
  Map<String, dynamic>? trigger(
    String? deviceId,
    SettingReqParams? requestParams,
  ) {
    requestParams!.deviceId = deviceId;
    requestParams.serviceId = "systemWorkingStatus";

    return {
      "deviceId": requestParams.deviceId,
      "serviceId": requestParams.serviceId,
      "input": requestParams.input,
    };
  }
}

/// 电池组工作模式（风冷、液冷）
class BatteryPackOperatingMode implements InstructionSetStrategy {
  @override
  Map<String, dynamic>? trigger(
    String? deviceId,
    SettingReqParams? requestParams,
  ) {
    requestParams!.deviceId = deviceId;
    requestParams.serviceId = "batteryPackOperatingMode";

    return {
      "deviceId": requestParams.deviceId,
      "serviceId": requestParams.serviceId,
      "input": requestParams.input,
    };
  }
}

/// BMS主接触器控制（风冷、液冷）
class BMSMainContactorControl implements InstructionSetStrategy {
  @override
  Map<String, dynamic>? trigger(
    String? deviceId,
    SettingReqParams? requestParams,
  ) {
    requestParams!.deviceId = deviceId;
    requestParams.serviceId = "bmsOpenAndClose";

    return {
      "deviceId": requestParams.deviceId,
      "serviceId": requestParams.serviceId,
      "input": requestParams.input,
    };
  }
}

/// 系统复位（风冷、液冷）
class SystemReset implements InstructionSetStrategy {
  @override
  Map<String, dynamic>? trigger(
    String? deviceId,
    SettingReqParams? requestParams,
  ) {
    requestParams!.deviceId = deviceId;
    requestParams.serviceId = "systemReset";
    requestParams.input = {"systemReset": "1"};

    return {
      "deviceId": requestParams.deviceId,
      "serviceId": requestParams.serviceId,
      "input": requestParams.input,
    };
  }
}

/// 系统使能设置（风冷、液冷）
class SettingSysEnable implements InstructionSetStrategy {
  @override
  Map<String, dynamic>? trigger(
    String? deviceId,
    SettingReqParams? requestParams,
  ) {
    requestParams!.deviceId = deviceId;
    requestParams.serviceId = "SettingSysEnable";

    return {
      "deviceId": requestParams.deviceId,
      "serviceId": requestParams.serviceId,
      "input": requestParams.input,
    };
  }
}

/// 系统校时设置（风冷、液冷）
class CorrectionTime implements InstructionSetStrategy {
  @override
  Map<String, dynamic>? trigger(
    String? deviceId,
    SettingReqParams? requestParams,
  ) {
    requestParams!.deviceId = deviceId;
    requestParams.serviceId = "correctionTime";

    return {
      "deviceId": requestParams.deviceId,
      "serviceId": requestParams.serviceId,
      "input": requestParams.input,
    };
  }
}

/// 变流器保护参数设置（风冷）
class ConverterProtectionParameterSettings implements InstructionSetStrategy {
  @override
  Map<String, dynamic>? trigger(
    String? deviceId,
    SettingReqParams? requestParams,
  ) {
    requestParams!.deviceId = deviceId;
    requestParams.serviceId = "converterProtectionParameterSettings";

    return {
      "deviceId": requestParams.deviceId,
      "serviceId": requestParams.serviceId,
      "input": requestParams.input,
    };
  }
}

// {
//   "accessType": "push",
//   "groupName": "变流器保护参数设置",
//   "id": "converterProtectionParameterSettings",
//   "name": "变流器保护参数设置",
//   "outputData": [
//     {
//       "dataType": {
//         "specs": {
//           "max": "10000000000",
//           "min": "0",
//           "unit": "kW",
//           "unitName": "千瓦"
//         },
//         "type": "double"
//       },
//       "id": "CONVGChargingPowerLimit",
//       "name": "变流器一般充电功率限值",
//   "sortOrder": "1"
// },
// {
//   "dataType": {
//     "specs": {
//       "max": "10000000000",
//       "min": "0",
//       "unit": "kW",
//       "unitName": "千瓦"
//     },
//     "type": "double"
//   },
//   "id": "ConverterSevereChargingPowerLimit",
//   "name": "变流器严重充电功率限值",
//   "sortOrder": "2"
// },
// {
//   "dataType": {
//     "specs": {
//       "max": "10000000000",
//       "min": "0",
//       "unit": "kW",
//       "unitName": "千瓦"
//     },
//     "type": "double"
//   },
//   "id": "ConverterGeneralInverterPowerLimit",
//   "name": "变流器一般逆变功率限值",
//   "sortOrder": "3"
// },
// {
//   "dataType": {
//     "specs": {
//       "max": "10000000000",
//       "min": "0",
//       "unit": "kW",
//       "unitName": "千瓦"
//     },
//     "type": "double"
//   },
//   "id": "ConverterSevereInverterPowerLimitation",
//   "name": "变流器严重逆变功率限值",
//   "sortOrder": "4"
// },
// {
//   "dataType": {
//     "specs": {
//       "max": "10000000000",
//       "min": "0",
//       "unit": "V",
//       "unitName": "伏特"
//     },
//     "type": "double"
//   },
//   "id": "converterGeneralOvervoltageLimit",
//   "name": "变流器一般过压限值",
//   "sortOrder": "5"
// },
// {
//   "dataType": {
//     "specs": {
//       "max": "10000000000",
//       "min": "0",
//       "unit": "V",
//       "unitName": "伏特"
//     },
//     "type": "double"
//   },
//   "id": "converterSevereOvervoltageLimit",
//   "name": "变流器严重过压限值",
//   "sortOrder": "6"
// },
// {
//   "dataType": {
//     "specs": {
//       "max": "10000000000",
//       "min": "0",
//       "unit": "V",
//       "unitName": "伏特"
//     },
//     "type": "double"
//   },
//   "id": "converterGeneralUndervoltageLimit",
//   "name": "变流器一般欠压限值",
//   "sortOrder": "7"
// },
// {
//   "dataType": {
//     "specs": {
//       "max": "10000000000",
//       "min": "0",
//       "unit": "V",
//       "unitName": "伏特"
//     },
//     "type": "double"
//   },
//   "id": "converterSevereUndervoltageLimit",
//   "name": "变流器严重欠压限值",
//   "sortOrder": "8"
// },
// {
//   "dataType": {
//     "specs": {
//       "max": "10000000000",
//       "min": "0",
//       "unit": "A",
//       "unitName": "安培"
//     },
//     "type": "double"
//   },
//   "id": "converterSevereUndervoltageLimit",
//   "name": "变流器一般充电电流限值",
//   "sortOrder": "9"
// },
// {
//   "dataType": {
//     "specs": {
//       "max": "10000000000",
//       "min": "0",
//       "unit": "A",
//       "unitName": "安培"
//     },
//     "type": "double"
//   },
//   "id": "converterSevereChargingCurrentLimit",
//   "name": "变流器严重充电电流限值",
//   "sortOrder": "10"
// },
// {
//   "dataType": {
//     "specs": {
//       "max": "10000000000",
//       "min": "0",
//       "unit": "A",
//       "unitName": "安培"
//     },
//     "type": "double"
//   },
//   "id": "ConverterGeneralInverterCurrentLimit",
//   "name": "变流器一般逆变电流限值",
//   "sortOrder": "11"
// },
// {
//   "dataType": {
//     "specs": {
//       "max": "10000000000",
//       "min": "0",
//       "unit": "A",
//       "unitName": "安培"
//     },
//     "type": "double"
//   },
//   "id": "ConverterSevereInverterCurrentLimit",
//   "name": "变流器严重逆变电流限值",
//   "sortOrder": "12"
// },
// {
//   "dataType": {
//     "specs": {
//       "max": "10000000000",
//       "min": "0",
//       "unit": "℃",
//       "unitName": "摄氏度"
//     },
//     "type": "double"
//   },
//   "id": "converterGeneralOverTemperatureLimit",
//   "name": "变流器一般过温限值",
//   "sortOrder": "13"
// },
// {
//   "dataType": {
//     "specs": {
//       "max": "10000000000",
//       "min": "0",
//       "unit": "℃",
//       "unitName": "摄氏度"
//     },
//     "type": "double"
//   },
//   "id": "converterSevereOverTemperatureLimit",
//   "name": "变流器严重过温限值",
//   "sortOrder": "14"
// },
// {
//   "dataType": {
//     "specs": {
//       "max": "10000000000",
//       "min": "0",
//       "unit": "℃",
//       "unitName": "摄氏度"
//     },
//     "type": "double"
//   },
//   "id": "converterGeneralLowTemperatureLimit",
//   "name": "变流器一般低温限值",
//   "sortOrder": "15"
// },
// {
//   "dataType": {
//     "specs": {
//       "max": "10000000000",
//       "min": "0",
//       "unit": "℃",
//           "unitName": "摄氏度"
//         },
//         "type": "double"
//       },
//       "id": "converterSevereLowTemperatureLimit",
//       "name": "变流器严重低温限值",
//       "sortOrder": "16"
//     }
//   ],
//   "prompt": "executeName"
// }

/// 变流器保护参数设置（液冷）
class LiquidCoolingConProParSettings implements InstructionSetStrategy {
  @override
  Map<String, dynamic>? trigger(
    String? deviceId,
    SettingReqParams? requestParams,
  ) {
    requestParams!.deviceId = deviceId;
    requestParams.serviceId = "converterProtectionParameterSettings";

    return {
      "deviceId": requestParams.deviceId,
      "serviceId": requestParams.serviceId,
      "input": requestParams.input,
    };
  }
}

///  交流器电网参数设置（风冷、液冷）
class ConverterGridParameterSettings implements InstructionSetStrategy {
  @override
  Map<String, dynamic>? trigger(
    String? deviceId,
    SettingReqParams? requestParams,
  ) {
    requestParams!.deviceId = deviceId;
    requestParams.serviceId = "GridParameterSettings";

    return {
      "deviceId": requestParams.deviceId,
      "serviceId": requestParams.serviceId,
      "input": requestParams.input,
    };
  }
}

/// 电池设置之系统使能设置（风冷、液冷）
class EnableBatterySystemSelfStartFunction implements InstructionSetStrategy {
  @override
  Map<String, dynamic>? trigger(
    String? deviceId,
    SettingReqParams? requestParams,
  ) {
    requestParams!.deviceId = deviceId;
    requestParams.serviceId = "EnableBatterySystemSelfStartFunction";

    return {
      "deviceId": requestParams.deviceId,
      "serviceId": requestParams.serviceId,
      "input": requestParams.input,
    };
  }
}

/// 电池保护参数设置（风冷）
class BatteryProtectionParameterSettings implements InstructionSetStrategy {
  @override
  Map<String, dynamic>? trigger(
    String? deviceId,
    SettingReqParams? requestParams,
  ) {
    requestParams!.deviceId = deviceId;
    requestParams.serviceId = "BatteryProtectionParameterSettings";

    return {
      "deviceId": requestParams.deviceId,
      "serviceId": requestParams.serviceId,
      "input": requestParams.input,
    };
  }
}

/// 电池保护参数设置（液冷）
class LiquidCoolingBatProParSettings implements InstructionSetStrategy {
  @override
  Map<String, dynamic>? trigger(
    String? deviceId,
    SettingReqParams? requestParams,
  ) {
    requestParams!.deviceId = deviceId;
    requestParams.serviceId = "BatteryProtectionParameterSettings";

    return {
      "deviceId": requestParams.deviceId,
      "serviceId": requestParams.serviceId,
      "input": requestParams.input,
    };
  }
}
